<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
  <title>学生界面</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 20px;
      background-color: #f5f5f5;
    }
    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
      padding-bottom: 10px;
      border-bottom: 1px solid #ddd;
    }
    .welcome {
      font-size: 18px;
      color: #333;
    }
    .logout-btn {
      padding: 5px 15px;
      background-color: #dc3545;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      text-decoration: none;
    }
    .logout-btn:hover {
      background-color: #c82333;
    }
    .content {
      background-color: white;
      padding: 20px;
      border-radius: 5px;
      box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 20px;
    }
    th, td {
      border: 1px solid #ddd;
      padding: 12px;
      text-align: left;
    }
    th {
      background-color: #f2f2f2;
    }
    tr:nth-child(even) {
      background-color: #f9f9f9;
    }
    .action-btn {
      padding: 5px 10px;
      margin-right: 5px;
      text-decoration: none;
      border-radius: 3px;
    }
    .edit-btn {
      background-color: #007bff;
      color: white;
    }
    .delete-btn {
      background-color: #dc3545;
      color: white;
    }
    .add-btn {
      display: inline-block;
      padding: 8px 16px;
      background-color: #28a745;
      color: white;
      text-decoration: none;
      border-radius: 4px;
      margin-bottom: 15px;
    }
    .add-btn:hover {
      background-color: #218838;
    }
    .user-info {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .user-type {
      background-color: #6c757d;
      color: white;
      padding: 2px 8px;
      border-radius: 10px;
      font-size: 0.8rem;
    }
    .search-form {
      margin-bottom: 20px;
      display: flex;
      gap: 10px;
    }
    .search-input {
      flex: 1;
      padding: 8px;
      border: 1px solid #ddd;
      border-radius: 4px;
    }
    .search-btn {
      padding: 8px 16px;
      background-color: #17a2b8;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
    }
    .grades-btn {
      background-color: #6f42c1;
      color: white;
    }
    .dashboard-card {
      background: white;
      border-radius: 8px;
      padding: 15px;
      margin-bottom: 20px;
      box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    .dashboard-card h3 {
      margin-top: 0;
      color: #4361ee;
    }
    .stats {
      font-size: 24px;
      font-weight: bold;
      margin: 10px 0;
      color: #333;
    }
  </style>
</head>
<body>
<div class="header">
  <h1>学生信息管理系统</h1>
  <div class="user-info">
    <span class="welcome">欢迎, ${username}</span>
    <span class="user-type">${userType}</span>
    <a href="${pageContext.request.contextPath}/user/logout" class="logout-btn">退出登录</a>
  </div>
</div>

<div class="content">
  <div class="dashboard-card">
    <h3>个人信息概览</h3>
    <div class="stats">5 门课程 | 平均分 85.6</div>
    <div>
      <a href="/student/grades" class="action-btn grades-btn">查看成绩</a>
      <a href="/student/courses" class="action-btn edit-btn">我的课程</a>
    </div>
  </div>

  <form action="/student/students" method="get" class="search-form">
    <input type="text" name="keyword" placeholder="输入姓名或学号搜索..." class="search-input" value="${param.keyword}">
    <button type="submit" class="search-btn">搜索</button>
    <a href="/student/students" class="action-btn">重置</a>
  </form>

  <a href="addStudent" class="add-btn">添加学生</a>

  <table>
    <thead>
    <tr>
      <th>ID</th>
      <th>姓名</th>
      <th>邮箱</th>
      <th>电话</th>
      <th>院系</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="student" items="${students}">
      <tr>
        <td>${student.id}</td>
        <td>${student.name}</td>
        <td>${student.email}</td>
        <td>${student.phone}</td>
        <td>${student.department}</td>
        <td>
          <a href="updateStudent?id=${student.id}" class="action-btn edit-btn">编辑</a>
          <a href="deleteStudent?id=${student.id}"
             onclick="return confirm('确定要删除此学生吗?')"
             class="action-btn delete-btn">删除</a>
          <a href="/student/grades?id=${student.id}" class="action-btn grades-btn">成绩</a>
        </td>
      </tr>
    </c:forEach>
    </tbody>
  </table>
</div>
</body>
</html>